﻿'use strict';
eventsApp.controller('eventCtrl', function eventCtrl($scope, eventData,$timeout,$cacheFactory, $routeParams) {
    var promise = $timeout(function () {
        $scope.admin = "simpa";
    }, 5000);

   // var myfcache = $cacheFactory('myfcache');
    $scope.Event = eventData.event;
    $scope.sortOrder = 'upVoteCount';
    $scope.Upvote = function (session) {
               session.upVoteCount++;   
    }
    $scope.Simpa = function (Event) {
        var dimpa = {
            "name": "Simpa Controllers",
            "creatorName": "Simpa",
            "duration": 4,
            "level": "Intermediate",
            "abstract": "Controllers are the beginning of everything Angular does.  Learn how to craft controllers that will win the respect of your friends and neighbors.",
            "upVoteCount": 0

        }
        
      //  myfcache.put('sample',dimpa);
        Event.session.push(dimpa);
        console.log(Event.session);
       // console.log(myfcache.info());

    }
    $scope.newName = function (session) {
        // session.name = session.name.reverse();//"hahaha"
        var patientData = eventData.getPatient();
        patientData.then(
            function (data) {
                console.log(data);
                alert("done");
            },
            function (status) {
                console.log(status);
            }
        )

       // var mydata = myfcache.get('sample');
        console.log(mydata);
    };

    $scope.Downvote = function (session) {

        session.upVoteCount--;
       
    };

   
   

});